home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / duckie / code.lua next >
Text File  |  2005-07-16  |  3KB  |  108 lines

  1.  
  2. -- -----------------------------------------------------------------
  3. -- Init
  4. -- -----------------------------------------------------------------
  5. local function prog_init()
  6.     initModels()
  7.     sound_playMusic("music/rybky03.ogg")
  8.     local pokus = getRestartCount()
  9.  
  10.  
  11.     -- -------------------------------------------------------------
  12.     local function prog_init_room()
  13.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  14.  
  15.         room.osneh = 0
  16.         room.okach = 0
  17.         room.okoh = 0
  18.         room.oanim = 0
  19.  
  20.         return function()
  21.             if isReady(small) and isReady(big) and no_dialog() then
  22.                 if room.oanim == 1 then
  23.                     room.oanim = 3
  24.                     addm(random(50) + 20, "odp-m-predmet")
  25.                     switch(random(4)){
  26.                         [0] = function()
  27.                             addv(5, "odp-v-pozadi")
  28.                         end,
  29.                         [1] = function()
  30.                             addv(5, "odp-v-pohni")
  31.                         end,
  32.                         default = function()
  33.                             addv(5, "odp-v-coja")
  34.                             planSet(big, "xichtit", 1)
  35.                             adddel(random(20) + 15)
  36.                             planSet(big, "xichtit", 0)
  37.                             addv(3, "odp-v-nestacim")
  38.                         end,
  39.                     }
  40.                 elseif room.osneh == 0 and big:isLeft() and small:isLeft() and random(1000) < 2 then
  41.                     addv(5, "odp-v-snehulak")
  42.                     addm(random(10), "odp-m-blaznis")
  43.                     room.osneh = 1
  44.                     if room.oanim == 0 and random(100) < 60 then
  45.                         room.oanim = 1
  46.                     end
  47.                 elseif room.okoh == 0 and math.abs(xdist(kohoutek, big)) <= 1 and random(1000) < 3 then
  48.                     addm(10, "odp-m-kohout")
  49.                     addv(10, "odp-v-vtip")
  50.                     room.okoh = 1
  51.                 elseif room.okach == 0 and random(1000) < 1 then
  52.                     addv(100, "odp-v-kachna")
  53.                     addm(5, "odp-m-zda" ..random(2))
  54.                     room.okach = 1
  55.                     if room.oanim == 0 and random(100) < 90 then
  56.                         room.oanim = 1
  57.                     end
  58.                 end
  59.             end
  60.         end
  61.     end
  62.  
  63.     -- -------------------------------------------------------------
  64.     local function prog_init_big()
  65.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  66.         local xicht = 0
  67.  
  68.         big.xichtit = 0
  69.  
  70.         return function()
  71.             if big.xichtit == 1 then
  72.                 xicht = random(9)
  73.             else
  74.                 xicht = 0
  75.             end
  76.             if xicht ~= 0 then
  77.                 big:useSpecialAnim("head_all", xicht)
  78.             end
  79.  
  80.         end
  81.     end
  82.  
  83.     -- --------------------
  84.     local update_table = {}
  85.     local subinit
  86.     subinit = prog_init_room()
  87.     if subinit then
  88.         table.insert(update_table, subinit)
  89.     end
  90.     subinit = prog_init_big()
  91.     if subinit then
  92.         table.insert(update_table, subinit)
  93.     end
  94.     return update_table
  95. end
  96. local update_table = prog_init()
  97.  
  98.  
  99. -- -----------------------------------------------------------------
  100. -- Update
  101. -- -----------------------------------------------------------------
  102. function prog_update()
  103.     for key, subupdate in pairs(update_table) do
  104.         subupdate()
  105.     end
  106. end
  107.  
  108.